home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Other View Systems / PowerPlant PPob / FWPPobRd.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.0 KB  |  143 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPPobRd.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWPPOBRD_H
  11. #define FWPPOBRD_H
  12.  
  13. #ifndef FWTXTBOX_H
  14. #include "FWTxtBox.h"
  15. #endif
  16.  
  17. //========================================================================================
  18. // Forward declarations
  19. //========================================================================================
  20.  
  21. class FW_CReadableStream;
  22. class FW_CSuperView;
  23. class FW_CFrame;
  24. class FW_MReceiver;
  25. class FW_CScrollBarScroller;
  26. struct Environment;
  27. class FW_CPPobScrollBarScroller;
  28. class FW_PResourceFile;
  29. class FW_PFileSpecification;
  30. class FW_CString;
  31. class FW_CFont;
  32.  
  33. //========================================================================================
  34. //     Some PowerPlant Types & Constants
  35. //========================================================================================
  36.  
  37. // PowerPlant resource types
  38. #define FW_kPPobType        'PPob'
  39. #define FW_kRidLType        'RidL'
  40. #define FW_kWINDType        'WIND'
  41.  
  42. typedef    short        ResIDT;
  43. typedef    long        PaneIDT;
  44. typedef    long        ClassIDT;
  45.  
  46. typedef void*        (*ClassCreatorFunc)(Environment*, FW_CReadableStream&, ClassIDT);
  47.  
  48. #pragma options align=mac68k
  49.  
  50. typedef struct ClassTable {
  51.     ClassIDT            classID;
  52.     ClassCreatorFunc    creatorFunc;
  53. } ClassTable, *ClassTableP, **ClassTableH;
  54.  
  55. #pragma options align=reset
  56.  
  57. // New ODF error (to move later to FWErrors.h).  Also defined in FWMARead.h
  58. #ifndef FW_xWrongViewResourceVersion
  59. #define FW_xWrongViewResourceVersion     -30215
  60. #endif
  61.  
  62. // Macro
  63. #define PPOB_WARNING(str)  if(FW_CPPobReader::gUseDebugWarnings) FW_DEBUG_MESSAGE(str)
  64.  
  65. //========================================================================================
  66. // class FW_CPPobReader
  67. //========================================================================================
  68.  
  69. class    FW_CPPobReader {
  70. public:
  71.     enum EResourceFileKind { kPartOnly, kPartOrAskUser, kCurrentResFile, kNewResFile };
  72.     enum EErrorKind { kNoError, kNoViewResource, kStreamReadError };
  73.  
  74.     // Class registration
  75.     static void             RegisterAllPPClasses();
  76.     static void                RegisterClass(ClassIDT inClassID, ClassCreatorFunc inCreatorFunc);                                
  77.  
  78.     // Main entry point to load PPob views
  79.     static FW_PlatformError    CreateSubViewsFromPPobResource(Environment* ev, 
  80.                                                     FW_ResourceID resourceID, 
  81.                                                     FW_CSuperView* superview,
  82.                                                     FW_MReceiver* receiver,
  83.                                                     EResourceFileKind resFileKind,
  84.                                                     FW_Boolean useDebugWarnings = true);
  85.                                                     
  86.     // Dynamic reloading of views
  87.     static FW_PlatformError ReloadViews(Environment* ev, 
  88.                                         FW_ResourceID resourceID, 
  89.                                         FW_CFrame* frame, 
  90.                                         FW_MReceiver* receiver,
  91.                                         EResourceFileKind resFileKind,
  92.                                         FW_Boolean useDebugWarnings = true);
  93.  
  94.     // Utilities 
  95.     static void                UseClassAlias(FW_Boolean flag) { gUseClassAlias = flag; };
  96.     static FW_Boolean        FoundViewWithAlias() { return gFoundViewWithAlias; };
  97.     static FW_PResourceFile* GetResFile(Environment* ev, EResourceFileKind resFileKind);
  98.     static FW_Boolean        HasResFile() { return (gCurResFileSpec != 0); } ;
  99.     static void                GetResFileName(Environment* ev, FW_CString& name);
  100.     static FW_CString         ReadStr255(FW_CReadableStream& stream);
  101.     static void             GetTextTraits(short textTraitsID, 
  102.                                     FW_CFont& font, 
  103.                                     FW_TextBoxOptions& horizJust,
  104.                                     FW_CColor& color);        
  105.                             
  106.     // For internal use
  107. private:
  108.     static void*    CreateObject(Environment* ev, FW_CReadableStream& inStream, 
  109.                                 ClassIDT classID, ClassIDT oldClassID);    
  110.     
  111.     static void*     ReadWindowPPob(Environment* ev, FW_CReadableStream& strean, ClassIDT id);
  112.     static void*     ReadDialogPPob(Environment* ev, FW_CReadableStream& strean, ClassIDT id);
  113.     
  114.     static void        LinkReceiverToControls(Environment* ev, FW_MReceiver* receiver,
  115.                             FW_CSuperView* container, FW_ResourceID resourceID);
  116.     static void        DisposeClassTable();
  117.     static void*    CreateUnknowView(Environment* ev, FW_CReadableStream& inStream, ClassIDT inClassID);
  118.     static short    FetchClassIndex(ClassIDT inClassID);
  119.     static void     ObjectsFromStream(Environment* ev, FW_CReadableStream& stream);
  120.     static void     SetWindow(Environment* ev, FW_PResourceFile& resFile, FW_ResourceID resourceID);
  121.     static void     PrivLinkReceiver(Environment* ev, FW_PResourceFile& resFile,
  122.                         FW_MReceiver* receiver, FW_CSuperView* container, FW_ResourceID resourceID);
  123.     static void     PostCreateViewFromStream(Environment* ev, FW_CSuperView* view);
  124.  
  125.     // Class globales
  126. public:
  127.     static FW_CSuperView*                gDefaultSuperView;
  128.     static FW_CPPobScrollBarScroller*    gScroller;
  129.     static PaneIDT                        gDefaultButtonID;
  130.     static PaneIDT                        gCancelButtonID;
  131.     static FW_Boolean                    gUseDebugWarnings;
  132.  
  133. private:
  134.     static short                        gClassCount;
  135.     static ClassTableH                    gTableH;
  136.     static FW_PFileSpecification*        gCurResFileSpec;
  137.     static FW_Boolean                    gUseClassAlias;
  138.     static FW_Boolean                    gFoundViewWithAlias;
  139. };
  140.  
  141.  
  142. #endif
  143.